<?php
/**
 * Created by PhpStorm.
 * User: liminfi
 * Date: 2017/3/10
 * Time: 18:04
 */
// 该代码块用于接收用户消息，根据用户输入的消息类型进行判断，文本，图片，视频，位置，链接，语音等，并取得值，处理后给予响应。
// 接收用户消息
// 微信公众账号接收到用户的消息类型判断
//

$wechatObj = new SQLop();
$conn=$wechatObj->connectSQL();
if($conn){
    $wechatObj->querySQL($conn);
}
class SQLop
{
    public function querySQL($conn)
    {
        $sql = "SELECT * FROM players";
        $query = mysqli_query($conn, $sql);
        if ($query->num_rows > 0) {
            // 输出每行数据
            while($row = $query->fetch_assoc()) {
                echo "名字: ". $row["name"]. " - 积分: ". $row["score"]. " 描述： " . $row["Description"]."<br>";
            }
        } else {
            echo "0 个结果";
        }
    }

    public function connectSQL()
    {
        $servername = "localhost";
        $username = "root";
        $password = "";

// 创建连接
        $conn = mysqli_connect($servername, $username, $password, 'wx');
		$conn->query("SET NAMES utf8");
        return $conn;
    }
}